package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.RemoveDiscourseByCategoryIdBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateDiscourseBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateDiscourseCategoryBean;
import com.ymatou.iapi.csim.service.RemoveDiscourseByCategoryIdCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateDiscourseCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateDiscourseCategoryCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_discourse;
import com.ymttest.database.model.ymt_discoursecategory;
import com.ymttest.database.sqlwapper.CSIM.ymt_discourseWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_discoursecategoryWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*根据分类删除话术
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_RemoveDiscourseByCategoryId{
	private static RemoveDiscourseByCategoryIdBean bean;
	private static RemoveDiscourseByCategoryIdCall call;
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private ymt_discourseWapper discourseWapper=new ymt_discourseWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据分类删除话术");
	}

	@Before
	public void caseUp() {
		bean=new RemoveDiscourseByCategoryIdBean();
		call=new RemoveDiscourseByCategoryIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_RemoveDiscourseByCategoryId_1() {
		Logger.start(true,"根据分类删除话术");
		try {
            Logger.comment("前置条件");
            SaveOrUpdateDiscourseBean saveOrUpdateDiscourseBean=new SaveOrUpdateDiscourseBean();
            SaveOrUpdateDiscourseCall saveOrUpdateDiscourseCall=new  SaveOrUpdateDiscourseCall();
            
            saveOrUpdateDiscourseBean.setId(TestDataManager.getRandomUUID().toString());
            saveOrUpdateDiscourseBean.setCategoryId(TestDataManager.getRandomUUID().toString());
            saveOrUpdateDiscourseBean.setTitle("自动化测试_"+TestDataManager.getRandomNum(5));
            saveOrUpdateDiscourseBean.setCsId(csId);
            saveOrUpdateDiscourseBean.setSort(1);
            saveOrUpdateDiscourseBean.setRoleType("MAIJIA_KEFU");
            saveOrUpdateDiscourseCall.setData(saveOrUpdateDiscourseBean);
            saveOrUpdateDiscourseCall.callService();	
			
            bean.setId(saveOrUpdateDiscourseBean.getId());
			call.setData(bean);
			call.callService();	
			//验证
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			ymt_discourse discourse=discourseWapper.selectByPrimaryKey(saveOrUpdateDiscourseBean.getId());
			Logger.verifyEquals(-1, discourse.getAction(), "验证Action=-1:删除成功");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}